/**
 * jims
 */
package com.jims.master.modules.sys.service;

import java.util.List;

import com.jims.master.common.utils.ChineseCharToEnUtils;
import com.jims.master.common.web.impl.BaseDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jims.master.common.persistence.Page;
import com.jims.master.common.service.CrudService;
import com.jims.master.modules.sys.entity.BaseUnit;
import com.jims.master.modules.sys.dao.BaseUnitDao;

/**
 * Service
 * @author fanduo
 * @version 2017-06-12
 */
@Service
@Transactional(readOnly = true)
public class BaseUnitService extends CrudService<BaseUnitDao, BaseUnit> {
	@Autowired
	private BaseUnitDao baseUnitDao;
	public BaseUnit get(String id) {
		return super.get(id);
	}
	
	public List<BaseUnit> findList(BaseUnit baseUnit) {
		return super.findList(baseUnit);
	}
	
	public Page<BaseUnit> findPage(Page<BaseUnit> page, BaseUnit baseUnit) {
		return super.findPage(page, baseUnit);
	}
	
	@Transactional(readOnly = false)
	public int save(BaseUnit baseUnit) {
		baseUnit.setInputCode(ChineseCharToEnUtils.getAllFirstLetter(baseUnit.getName()));
		return super.save(baseUnit);
	}
	
	@Transactional(readOnly = false)
	public int delete(BaseUnit baseUnit) {
		return super.delete(baseUnit);
	}
	/**
	 * 根据单位查询所有分组
	 * @param unitId
	 * @return
	 * @author fanduo
	 */
	public List<BaseDto> findGroupByUnitId(String unitId){
		return baseUnitDao.findGroupByUnitId(unitId);
	}
	
}